var rateArr = [
	{
		text: '只响一次',
		value: 1
	},{
		text: '每天',
		value: 2
	},{
		text: '周一至周五',
		value: 3
	},{
		text: '自定义提醒',
		value: 4
	}
]
var sitAlarm = new Vue({
	el: '#sitAlarm',
	data: {
		info: {
			frequency: 1
		},
		showAdd: false,
		datePicker: '',
		startDate: new Date(),
		hour: Array(24).fill(1).map((v, k) => k < 10 ? '0'+k:k+''),
		minute: Array(60).fill(1).map((v, k) => k < 10 ? '0'+k:k+''),
		list: [{
			schedule: "0 0 8 ? * 1-4",
			status: 1
		},{
			time: "0 15 10 ? * MON-FRI",
			status: 1
		},{
			time: '08:00',
			status: 1
		}],
		options: [
			{
				label: '星期一',
				value: 1
			},{
				label: '星期二',
				value: 2
			},{
				label: '星期三',
				value: 3
			},{
				label: '星期四',
				value: 4
			},{
				label: '星期五',
				value: 5
			},{
				label: '星期六',
				value: 6
			},{
				label: '星期日',
				value: 7
			}
		],
		rateList: rateArr,
		slots: [{
			flex: 1,
			values: rateArr,
			textAlign: 'left',
			className: 'rate'
		}],
		popupVisible: false,
		customPop: false,
		pickerTit: '提醒',
		custom: [],
		alarmSlots: []
	},
	mounted() {
	},
	methods: {
		// 确认添加 - 修改
		addConfirm(){
			this.showAdd = false;
		},
		// 点击列表详情
		editAlarm(info){
			this.showAddFunc()
		},
		// 闹钟时间选择
		alarmPicker(date){

		},
		// 保存提醒频率
		onValuesChange(_, values) {
			if(values[0]){
				this.info.frequency = values[0].value
				if(this.info.frequency === 4){
					this.customPop = true
				}
			}
		},
		// 显示添加-修改页面
		showAddFunc(){
			let h = dayjs(this.startDate).format('HH');
			let m = dayjs(this.startDate).format('mm');
			this.showAdd = true;
			this.alarmSlots = [{
				flex: 1,
				values: this.hour,
				defaultIndex: this.hour.map(v => v).indexOf(h)
			},{
				flex: 1,
				values: this.minute,
				defaultIndex: this.minute.map(v => v).indexOf(m)
			}]
		},
		// 取消
		cancel(){
			this.customPop = false;
			this.slots = [{
				flex: 1,
				values: this.rateList,
				defaultIndex: 2,
				textAlign: 'left',
				className: 'rate'
			}]
		}
	},
	filters: {
		
	}
})
